<?php 
/*Widgets used in the YUI Theme.*/

function yui_subscribeto($feedone = array(), $feedtwo = array()){
	if (empty($feedone) || empty($feedtwo)) return;
	?>
	
	<li id="yui_subscribe" class="widget widget_subscribe">
		<div class="widgettop"></div>
		<div class="widgetbody">
			<h4 class="widgettitle"><?php _e('Subscribe','yui-theme');?></h4>
			<div style="width:45%;float:left">
				<ul class="subitemlist">
					<li><a href="<?php echo $feedone['url'];?>" style="position: relative;"><?php echo $feedone['name'];?></a></li>
					<li><a target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=<?php echo $feedone['url'];?>" class="fszhuaxia"><span class="sig_add">[+]</span>订阅到<span style="font-weight:900;color:#86B540;">抓虾</span></a></li>
					<li><a target="_blank" href="http://fusion.google.com/add?feedurl=<?php echo $feedone['url'];?>" class="fsgoogle"><span class="sig_add">[+]</span>订阅到<span style="font-weight:900"><sapn style="color:#1851ce;">G</span><span style="color:#c61800;">o</span><span style="color:#efba00">o</span><span style="color:#1851ce">g</span><span style="color:#1ba823">l</span><span style="color:#c61800">e</span></span></a></li>
					<li><a target="_blank" href="http://add.my.yahoo.com/rss?url=<?php echo $feedone['url'];?>" class="fsyahoo"><span class="sig_add">[+]</span>订阅到<span style="font-weight:1000;color:#FC1921">Yahoo!</span></a></li>
					<li><a target="_blank" href="http://www.xianguo.com/subscribe.php?url=<?php echo $feedone['url'];?>" class="fsxianguo"><span class="sig_add">[+]</span>订阅到<span style="color:#F1311E">●</span><span style="font-weight:900;color:#0063DC">鲜果</span></a></li>
				</ul>
			</div>
			<div style="width:45%;float:left">
				<ul class="subitemlist">
					<li><a href="<?php echo $feedtwo['url'];?>" style="position: relative;"><?php echo $feedtwo['name'];?></a></li>
					<li><a target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=<?php echo $feedtwo['url'];?>" class="fbzhuaxia"><span class="sig_add">[+]</span>订阅到<span style="font-weight:900;color:#86B540;">抓虾</span></a></li>
					<li><a target="_blank" href="http://fusion.google.com/add?feedurl=<?php echo $feedtwo['url'];?>" class="fbgoogle"><span class="sig_add">[+]</span>订阅到<span style="font-weight:900"><sapn style="color:#1851ce;">G</span><span style="color:#c61800;">o</span><span style="color:#efba00">o</span><span style="color:#1851ce">g</span><span style="color:#1ba823">l</span><span style="color:#c61800">e</span></span></a></li>
					<li><a target="_blank" href="http://add.my.yahoo.com/rss?url=<?php echo $feedtwo['url'];?>" class="fbyahoo"><span class="sig_add">[+]</span>订阅到<span style="font-weight:1000;color:#FC1921">Yahoo!</span></a></li>
					<li><a target="_blank" href="http://www.xianguo.com/subscribe.php?url=<?php echo $feedtwo['url'];?>" class="fbxianguo"><span class="sig_add">[+]</span>订阅到<span style="color:#F1311E">●</span><span style="font-weight:900;color:#0063DC">鲜果</span></a></li>
				</ul>
			</div>
			<div style="clear:both"></div>
		</div>
		<div class="widgetbottom"></div>
	</li>
	
	<?php
}

function yui_recentposts() {
	if (function_exists('wkc_recent_posts')) {
	?>
	
	<li id="yui_recentposts" class="widget widget_recentposts">
		<div class="widgettop"></div>
		<div class="widgetbody">
			<h4 class="widgettitle"><?php _e('Latest Posts','yui-theme');?></h4>
			<ul>
				<?php wkc_recent_posts('number=10&before=<li>&after=</li>');?>
			</ul>
		</div>
		<div class="widgetbottom"></div>
	</li>
	<?php
	}
}

function yui_links() {
	?>
	
	<li id="yui_links" class="widget widget_links">
		<div class="widgettop"></div>
		<div class="widgetbody">
			<h4 class="widgettitle"><?php _e('Friends','yui-theme');?></h4>
			<?php
			$param = array(
				'title_li' => '',
				'title_before' => '', 
				'title_after' => '',
				'categorize' => 0,
				'orderby' => 'rand',
				'category' => '',
				'limit' => 40,
				'show_images' => false, 
				'class' => 'linkcat widget',
				'echo' => 0
			);
			$leftcol = get_bookmarks($param); 
			$rightcol = array_splice($leftcol, count($leftcol) / 2 + 0.6);
			?>
			<div style="width:47%;overflow:hidden;float:left">
				<ul>
				<?php
					foreach($leftcol as $bml){
						echo '<li class="linkitem">';
						echo '<a href="' . $bml->link_url .'" title="' . $bml->link_description . '">';
						echo $bml->link_name;
						echo '</a></li>' . "\n";
					}
				?>
				</ul>
			</div>
			<div style="width:47%;overflow:hidden;float:left">
				<ul>
				<?php
					foreach($rightcol as $bmr){
						echo '<li class="linkitem">';
						echo '<a href="' . $bmr->link_url .'" title="' . $bmr->link_description . '">';
						echo $bmr->link_name;
						echo '</a></li>' . "\n";
					}
				?>
				</ul>
			</div>
			<div style="clear:both"></div>
		</div>
		<div class="widgetbottom"></div>
	</li>
	<?php
}

function yui_randomposts() {
	if (function_exists('wkc_random_posts')){
		$args = array(
			'number'	=>	10,
			'length'	=>	100, 
			'before'	=>	'<li>', 
			'after'		=>	'</li>', 
			'showpass'	=>	0,
			'showexcerpt'	=> 1,
			'echo'		=>	1
		);
		
		?>
	<li id="yui_randomposts" class="widget widget_randomposts">
		<div class="widgettop"></div>
		<div class="widgetbody">
			<h4 class="widgettitle"><?php _e('Random Posts','yui-theme');?></h4>
			<ul>
			<?php wkc_random_posts($args); ?>
			</ul>
		</div>
		<div class="widgetbottom"></div>
	</li>
		<?php
	}
}

function yui_samecategories() {
	if (!function_exists('wkc_posts_in_the_same_categories')) return;
	$args = array(
		'orderby' => 'date',
		'order'	  => 'desc',
		'number'  => 10
	);
	?>
	
	<li id="yui_samecategoriess" class="widget widget_samecategories">
		<div class="widgettop"></div>
		<div class="widgetbody">
			<h4 class="widgettitle"><?php _e('In this Category','yui-theme');?></h4>
			<ul>
			<?php wkc_posts_in_the_same_categories($args); ?>
			</ul>
		</div>
		<div class="widgetbottom"></div>
	</li>
	<?php
}

function yui_relatedposts() {
	if (!function_exists('wkc_related_posts')) return;
	$args = array(
		'number'  => 10
	);
	?>
	
	<li id="yui_relatedposts" class="widget widget_relatedposts">
		<div class="widgettop"></div>
		<div class="widgetbody">
			<h4 class="widgettitle"><?php _e('Related Posts','yui-theme');?></h4>
			<ul>
			<?php wkc_related_posts($args); ?>
			</ul>
		</div>
		<div class="widgetbottom"></div>
	</li>
	<?php
}

function yui_recentcomments($skipuser){
	if(!function_exists('wkc_recent_comments')) return;
	$args = array(
		'number'	=>	10,
		'length'	=>	30,
		'skipuser'	=>	$skipuser,
		'avatarsize'=>  16,
		'xformat'	=>  '<a class="commentor" href="%comment_author_url%" >%comment_author%</a> : <a class="comment_content" href="%permalink%" title="View the entire comment by %comment_author%" >%comment_excerpt%</a>',
		'echo'		=>	1
	);
	?>
	
	<li id="yui_recentcomments" class="widget widget_recentcomments">
		<div class="widgettop"></div>
		<div class="widgetbody">
			<h4 class="widgettitle"><?php _e('Recent Comments','yui-theme');?></h4>
			<ul>
			<?php wkc_recent_comments($args); ?>
			</ul>
		</div>
		<div class="widgetbottom"></div>
	</li>
	<?php
}
?>